<?php
namespace Vavilen\FirstBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class CategoryForm extends AbstractType
{
	public function buildForm(FormBuilderInterface $builder, array $options)
	{
		$builder->add('categoryName');
		$builder->add('url');
		$builder->add('parentCategory', 'entity', array(
		    'label'    => 'Parent category',
		    'class'    => 'VavilenFirstBundle:Category',
		    'property' => 'categoryName',
		    'empty_value' => 'родитель',
		    'required' => false,
		));
	}

	public function getName()
	{
		return 'category';
	}

	public function setDefaultOptions(OptionsResolverInterface $resolver)
	{
		$resolver->setDefaults(array(
		    'data_class' => 'Vavilen\FirstBundle\Entity\Category',
		));
	}
}